#ifndef _Code_To_X_H_
#define _Code_To_X_H_

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <locale.h>

#ifdef WIN32
#include <atlbase.h>
#else
#include <unistd.h>
#endif

#include <string>
using namespace std;

#define RTN_SUCCESS 1
#define RTN_ERROR -1
#define RELEASE_PTR(x) if ( x!= NULL ) { delete x;x = NULL;}
#define UTF16 unsigned short

long AtoW(char *ansi, wchar_t **unicode);
long WtoA(wchar_t *unicode, char **ansi);
long AssicToUTF8(char* pszAnsi, char** pszUTF8);

namespace Charset_Coders
{
	bool Unicode2UTF8( const wchar_t *input_unicode,
					   char ** p_output_utf8,
					   unsigned long *length );
    
    bool UTF162UTF8( const UTF16 *input_unicode,
                      char ** p_output_utf8,
                      unsigned long *length );

    bool UTF82Unicode( const char *input_utf8,
					   wchar_t** p_output_unicode,
					   unsigned long *length );
	//functions for external use
	size_t unicode2utf8(char *strinput, int len, char *stroutput, int maxoutlen);
	size_t utf82unicode(char *strinput, int len, char *stroutput, int maxoutlen);
	void string_utf82unicode(std::string &str);
	void string_unicode2utf8(std::wstring str, std::string &dest);
}

#endif //_Code_To_X_H_
